#pragma once
#include "ParamProcessing.h"
#include "Server.h"
#include "cstring"
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <fstream>

extern int fd;
extern int fd7000;

class Crc32
{
private:
  static const uint32_t crcTable[];

public:
  static uint32_t CRC(const uint8_t *bytes, int len);
};

class Message
{
public:
  int command;
  std::string data;
};

void MessageProcessor(Message message);

std::vector<uint8_t> EncodeMessage(int command, const std::string &data, int bytelength = Upper_Computer_Byte_Length);
std::vector<uint8_t> EncodeMessage(int command, const std::vector<uint8_t> &data, int bytelength = Upper_Computer_Byte_Length);
std::vector<Message> DecodeMessage(std::vector<uint8_t> &receivedBytes, int bytelength = Controller_Byte_Length);

char _getBase64Char(char c);
int calc_base64_len(int data_len);
void base64_encode(const char *pData, int len, char *pOut);
